import {
	request,
	baseUrl
} from "../request.js"

//域名 端口号
//var baseUrl = 'https://wzxlovemzy.com:6001/user'

/**
 * 1，获取关系列表
 * @param {Object} userId
 * @param {Object} relationType
 */
export function getRelationList(userId, relationType) {
	return request({
		url: baseUrl + '/relation/getRelationList?userId=' + userId + '&relationType=' + relationType,
		method: 'GET'
	})
}

/**
 * 2，同意或拒绝好友
 * @param {Object} sysId
 * @param {Object} state
 */
export function addFriend(item) {
	//console.log(item)
	return request({
		url: baseUrl + '/msg/addFriend',
		method: 'POST',
		data: {
			receiverId: item.receiverId,
			senderHead: item.senderHead,
			senderId: item.senderId,
			senderName: item.senderName,
			state: item.state,
			sysType: item.sysType,
			addId: item.addId,
			createTime: item.createTime,
			groupId: item.groupId,
			id: item.id,
			message: item.message
		}
	})

}

/**
 * 3，查询关系
 * @param {Object} userId
 * @param {Object} friendId
 */
export function queryRelationState(userId, friendId) {
	return request({
		url: baseUrl + '/relation/queryRelationState?userId=' + userId + '&friendId=' + friendId,
		method: 'GET'
	})
}

/**
 * 4，修改（是否查看动态，黑名单）状态
 * @param {Object} userId
 * @param {Object} friendId
 */
export function queryRelationStateaaaaa(userId, friendId) {
	return request({
		url: baseUrl + '/relation/queryRelationState?userId=' + userId + '&friendId=' + friendId,
		method: 'GET'
	})
}

/**
 * 5，修改用户在群聊中的备注
 * @param {Object} uid
 * @param {Object} fid
 * @param {Object} iInGroupRemarks
 */
export function changeRemarksByGroup(uid, fid, iInGroupRemarks) {
	return request({
		url: baseUrl + '/relation/changeRemarksByGroup',
		method: 'POST',
		data: {
			userId: uid,
			friendId: fid,
			groupRemark: iInGroupRemarks
		}
	})
}

/**
 * 6，将用户加入黑名单
 * @param {Object} userId
 * @param {Object} friendId
 */
export function addBlackUser(userId, friendId, changeType) {
	return request({
		url: baseUrl + '/relation/addBlackUser?userId=' + userId + '&friendId=' + friendId + '&changeType=' +
			changeType,
		method: 'GET'
	})
}

/**
 * 7，查询对方是否将我加入黑名单
 * @param {Object} userId
 * @param {Object} friendId
 */
export function queryIsBlack(userId, friendId) {
	return request({
		url: baseUrl + '/relation/queryIsBlack?userId=' + userId + '&friendId=' + friendId,
		method: 'GET'
	})
}

/**
 * 8，查询所有好友备注
 * @param {Object} userId
 */
export function queryAllUserFriendRemarks(userId) {
	return request({
		url: baseUrl + '/relation/queryAllUserFriendRemarks?userId=' + userId,
		method: 'GET'
	})
}


export function getRelationListBySearch(userId, relationType, searchName) {
	return request({
		url: baseUrl + '/relation/getRelationListBySearch',
		method: 'POST',
		data: {
			userId,
			relationType,
			searchName: searchName || ''
		}
	})
}